/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.alipay.supergw.common.dal.share_supergw.manual.ibatis;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alipay.supergw.common.dal.share_supergw.manual.daointerface.TransactionContentDAO;
import com.alipay.supergw.common.dal.share_supergw.manual.dataobject.TransactionContentDO;

/**
 * An ibatis based implementation of dao interface <tt>com.alipay.supergw.common.dal.share_supergw.auto.daointerface.TransactionContentDAO</tt>.
 *
 * This file is generated by <tt>supergw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>supergw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/sgw_transaction_content.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>supergw-dalgen</tt> 
 * to generate this file.
 */
public class IbatisTransactionContentDAO extends SqlMapClientDaoSupport implements
                                                                       TransactionContentDAO {

    /**
     *  Insert one <tt>TransactionContentDO</tt> object to DB table <tt>sgw_transaction_content</tt>, return primary key
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>insert into sgw_transaction_content(transaction_online_id,trans_type,trans_content,trans_content2,memo,gmt_create,gmt_modified) values (?, ?, ?, ?, ?, sysdate, sysdate)</tt>
     *
     *	@param transactionContent
     *	@return String
     *	@throws DataAccessException
     */
    @Override
    public String insert(TransactionContentDO transactionContent) throws DataAccessException {
        if (transactionContent == null) {
            throw new IllegalArgumentException("Can't insert a null data object into db.");
        }

        getSqlMapClientTemplate().insert("MS-TRANSACTION-CONTENT-INSERT", transactionContent);

        return transactionContent.getTransactionOnlineId();
    }

    /**
     *  Update DB table <tt>sgw_transaction_content</tt>.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>update sgw_transaction_content set trans_content=?, trans_content2=?, memo=?, gmt_modified=sysdate where ((transaction_online_id = ?) AND (trans_type = ?))</tt>
     *
     *	@param transactionContent
     *	@return int
     *	@throws DataAccessException
     */
    @Override
    public int update(TransactionContentDO transactionContent) throws DataAccessException {
        if (transactionContent == null) {
            throw new IllegalArgumentException("Can't update by a null data object.");
        }

        return getSqlMapClientTemplate()
            .update("MS-TRANSACTION-CONTENT-UPDATE", transactionContent);
    }

    /**
     *  Query DB table <tt>sgw_transaction_content</tt> for records.
     *
     *  <p>
     *  Description for this operation is<br>
     *  <tt></tt>
     *  <p>
     *  The sql statement for this operation is <br>
     *  <tt>select transaction_online_id, trans_type, trans_content, trans_content2, memo, gmt_create, gmt_modified from sgw_transaction_content where (transaction_online_id = ?)</tt>
     *
     *	@param transactionOnlineId
     *	@return List<TransactionContentDO>
     *	@throws DataAccessException
     */
    @Override
    @SuppressWarnings("unchecked")
    public List<TransactionContentDO> loadById(String transactionOnlineId)
                                                                          throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-TRANSACTION-CONTENT-LOAD-BY-ID",
            transactionOnlineId);

    }

}